//
//  MKCollectionSectionModel.h
//  MKUI
//	集合模型中的分组数据模型
//  Created by sushangjin on 14/11/19.
//  Copyright © 2020 sushangjin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "MKCollectionModelObjectBase.h"
NS_ASSUME_NONNULL_BEGIN

@class MKCollectionModel,MKCollectionCellModel;

@interface MKCollectionSectionModel : MKCollectionModelObjectBase
@property(nonatomic,strong,nullable) NSArray<__kindof MKCollectionCellModel *> *cellModels;//含有的单元格
@property(nonatomic,strong,nullable) id userInfo;//自定義的擴展對象
@property(nonatomic,readonly) NSInteger numberOfCells;//单元格数量
@property(nonatomic,readonly) NSInteger indexInModel;
@property(nonatomic,readonly,nullable) NSMutableArray<__kindof MKCollectionCellModel *> * mutableCellModels;
//弱引用外層的数据
- (void)setCollectionModel:(nullable MKCollectionModel *)collectionModel;
- (nullable __kindof MKCollectionModel *)collectionModel;

/**
 *  加到单元格到分组中
 *
 *  @param cellModel 单元格数据
 */
- (void)addCellModel:(MKCollectionCellModel *)cellModel;
- (void)addCellModels:(NSArray<MKCollectionCellModel *> *)cellModels;
- (void)insertCellModel:(MKCollectionCellModel *)cellModel atIndex:(NSInteger)index;
- (void)insertCellModels:(NSArray<MKCollectionCellModel *> *)cellModels afterIndex:(NSInteger)index;
- (void)insertCellModels:(NSArray<MKCollectionCellModel *> *)cellModels beforeIndex:(NSInteger)index;
/**
 *  单元格添加后的配置,@overrdie
 *
 *  @param cellModel 单元格
 */
- (void)configCellModelAfterAdding:(MKCollectionCellModel *)cellModel;
- (void)configCellModelAfterRemoving:(MKCollectionCellModel *)cellModel;

- (void)insertCellModelsToTop:(NSArray<MKCollectionCellModel *> *)cellModels;//添加到顶部
- (void)insertCellModelsToBottom:(NSArray<MKCollectionCellModel *> *)cellModels;//添加到底部

/**
 *  將cell從所有的分组中移除
 *
 *  @param cellModel 单元格對象
 */
- (void)removeCellModel:(MKCollectionCellModel *)cellModel;

/**
 *  移除index位置的单元格
 *
 *  @param index 索引位置
 */
- (void)removeCellModelAtIndex:(NSInteger)index;

/**
 *  移除多个单元格
 *
 *  @param indexes 索引位置集合
 */
- (void)removeCellModelsAtIndexes:(NSIndexSet *)indexes;

/**
 *	清空所有数据
 */
- (void)removeAllCellModels;

/**
 *  返回指定索引下的单元格数据
 *
 *  @param index 索引
 *
 *  @return 单元格数据
 */
- (nullable __kindof MKCollectionCellModel *)cellModelAtIndex:(NSInteger)index;

/**
 *  返回指定单元格数据对应的索引
 *
 *  @param cellModel 单元格数据
 *
 *  @return 索引号
 */
- (NSInteger)indexOfCellModel:(MKCollectionCellModel *)cellModel;

- (nullable NSIndexPath *)indexPathForSelectedCellModel;
- (nullable __kindof MKCollectionCellModel *)cellModelForSelectedCellModel;
- (nullable NSArray<NSIndexPath *> *)indexPathsForSelectedCellModels;
- (nullable NSArray<__kindof MKCollectionCellModel *> *)cellModelsForSelectedCellModels;

- (NSComparisonResult)compare:(MKCollectionSectionModel *)otherObject;
@end

@interface MKCollectionSectionModel(Focused)
@property(nonatomic,readonly) NSInteger indexForFocusedCellModel;
@property(nonatomic,readonly,nullable) __kindof MKCollectionCellModel *cellModelForFocusedCellModel;
@end

NS_ASSUME_NONNULL_END
